﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using FM.Common;
using FM.Events;
using FM.录音.Events;
using FM.录音.Services;
using FM.接口;
using Microsoft.Practices.Prism.Mvvm;

namespace FM.录音.ViewModels
{
    public class 主窗口ViewModel : BindableBase, I按键处理
    {
        private string _标题 = "电台录音系统";   
        private bool _is加载中=true ;
        public string 标题
        {
            get { return _标题; }
            set { SetProperty(ref _标题, value); }
        }
         
        public bool Is加载中
        {
            get { return _is加载中; }
            set { SetProperty(ref _is加载中, value); }
        }

        public 主窗口ViewModel()
        {
            if (小冰.新闻部 != null)
                小冰.新闻部.GetEvent<启动完毕Event>().Subscribe(x => Is加载中 = false);
        }

        public void 按键处理(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.F11:
                    if (e.KeyboardDevice.Modifiers == ModifierKeys.None)
                    {
                        运行状态.Is全屏 = !运行状态.Is全屏;
                        小冰.新闻部.GetEvent<全屏Event>().Publish(运行状态.Is全屏);
                    }
                    break;
                case Key.F2:
                    if (e.KeyboardDevice.Modifiers == ModifierKeys.None)
                        小冰.新闻部.GetEvent<进入选项Event>().Publish(null);
                    break;
            }
        }
    }
}